package com.zzl.boot.bigevent.mapper;

import com.zzl.boot.bigevent.pojo.comment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface commentMapper {

    @Select("insert into comment(content,author,article_id,create_time,parent_id,user_pic) " +
            "values (#{content},#{author},#{articleId},now(),#{parentId},#{userPic})")
    void add(comment comment);

    @Select("delete from comment where id=#{id}")
    void del(Integer id);
    //获取评论
    @Select("select * from comment where article_id=#{articleId} and parent_id=0 ORDER BY create_time" )
    List<comment> find(Integer id);
    //获取回复评论
    @Select("select * from comment where parent_id=#{id} ORDER BY create_time" )
    List<comment> findReply(Integer id);
    @Select("select * from comment where article_id=#{id} ORDER BY create_time" )
    List<comment> findArComment(Integer id);
}
